home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / amisl090.zip / AMISLIB.DOC < prev    next >
Text File  |  1992-09-12  |  15KB  |  395 lines

  1. Alternate Multiplex Interrupt Specification Library
  2. Public Domain 1992 Ralf Brown
  3. Version 0.90
  4. LastEdit: 9/12/92
  5.  
  6. Files in this library:
  7.     AMISLIB.DOC    this file
  8.     TSRS.DOC    usage instructions for sample TSRs and utilities
  9.     AMIS.MAC    include file defining various macros
  10.     AMIS.ASM    the actual library code
  11.     AMISHOTK.ASM    the library's hotkey collision detection code
  12.     AMIS.H        C include file defining various things
  13.     AMITSRS.C    sample program to list resident programs using AMIS
  14.     FINDTSRS.C    function to find all TSRs matching a given name
  15.     POPUP.C        sample program to request popup of an AMIS TSR
  16.     REMOVE.C    sample program to remove a specific AMIS TSR
  17.     UNINSTAL.ASM    TSR remover for REMOVE.C
  18.     FASTMOUS.ASM    sample TSR
  19.     NOLPT.ASM    sample TSR -- turn parallel port into bit bucket
  20.     SWITCHAR.ASM    sample TSR -- provide switchar() for MSDOS 5.0
  21.     VGABLANK.ASM    sample TSR -- VGA screen blanker
  22.     NOTE.ASM    sample TSR -- popup note-taker
  23.     MAKEFILE    make all programs from the library sources
  24.  
  25. ------------------------------------------------------------------------
  26.  
  27. Advantages of AMISLIB:
  28.  
  29.     totally free
  30.     adds only 1K to the executable -- TSRs can be as small as 1.4K
  31.       on disk and use little as 128 bytes in memory (hotkey
  32.       checking adds another 300 bytes of transient code)
  33.     up to 256 AMIS-compliant TSRs can be resident simultaneously
  34.       with no interrupt conflicts
  35.     resultant TSR can load itself into high memory (either MSDOS 5
  36.       upper memory blocks or XMS upper memory blocks); the user has
  37.       control over where TSR is allowed to load: high only, low only,
  38.       or high first then low; high memory may use either the first or
  39.       the best UMB; low memory may use either the low end or the high
  40.       end of conventional memory.
  41.     TSRs using AMISLIB or other AMIS-compliant code can detect
  42.       hotkey conflicts and either abort before installation or
  43.       attempt to use alternate hotkeys
  44.     TSRs using AMISLIB or other AMIS-compliant code can be unloaded
  45.       in any order, and can be unloaded by programs other than the
  46.       TSR's original executable
  47.  
  48. Note: This is still a preliminary version of the library, so there might
  49.       be problems.  Please let me know if you find any....
  50.  
  51. ------------------------------------------------------------------------
  52.  
  53. To make use of this library, you basically need to do four things:
  54.  
  55.     1. To each source file that will make calls, add
  56.         INCLUDE AMIS.MAC
  57.     2. In the source file containing the program's entry point, add
  58.         @Startup M,NN,SSS
  59.        just after the above INCLUDE and
  60.         @Startup2 <Y>
  61.        at the program's entry point (see below for details).
  62.     3. Change the END line of the main source file to
  63.         END INIT
  64.     4. Link in AMIS.OBJ (assembled from AMIS.ASM) with the rest of
  65.        your object modules.     If you are using hotkeys, also link in
  66.        AMISHOTK.OBJ.
  67.  
  68. Limitations:
  69.     The ALTMPX and INSTALL_TSR macros must be invoked from the same
  70.       source file in order for the installer to properly fix up the
  71.       resident AMIS handler.  (If not, you will have to perform the
  72.       fixup yourself in an 'init' handler for INSTALL_TSR)
  73.     AMISLIB currently limits the resident code/data (not counting 
  74.       the "extra" allocation at installation time) to 64K.
  75.  
  76. ------------------------------------------------------------------------
  77.  
  78. After an INCLUDE AMIS.MAC, the following definitions and macros are available:
  79.  
  80. AMIS_VERSION
  81.     100 times the version of the specification to which the library
  82.     conforms (i.e. 123 = version 1.2.3).
  83.  
  84. AMISLIB_VERSION
  85.     100 times the version of this library
  86.  
  87. @Startup
  88.     Declare all segments and provide some startup code.
  89.     Usage:    @Startup major,minor,stack
  90.     Arguments:
  91.     major    [opt] the minimum major version of DOS required to run
  92.     minor    [opt] the major minor version of DOS required to run
  93.     stack    [opt] the number of bytes of stack to provide at startup
  94.     Note:
  95.     If either <major> or <minor> is blank, the program will not
  96.     check the DOS version at startup.  If <stack> is blank, a
  97.     default stack of 256 bytes will be provided in memory models
  98.     other than Tiny (there is no stack in Tiny model, so this value
  99.     will be ignored).
  100.  
  101. @Startup2
  102.     Provide additional startup code at the program's actual entry
  103.     point. 
  104.     Usage:    @Startup2 psp
  105.     Arguments:
  106.     psp    [opt] if non-blank, allocate a public variable named __psp
  107.     Note:
  108.     <psp> should be blank if some other module (such as the C
  109.     runtime library) provides a public variable named __psp.
  110.  
  111. RESIDENT_CODE
  112.     The name of the segment to ASSUME or use in overrides when accessing
  113.     data within the part of the program which will remain resident.
  114.  
  115. TGROUP
  116.     Group containing all resident segments in the TSR.    See also
  117.     TGROUP@ and TSRgroup@.
  118.  
  119. TGROUP@
  120.     Symbol to use when loading a segment register to access the TSRs
  121.     resident portion in the executable.     In Tiny model, this will load
  122.     the value of TGROUP from a memory location; in other memory models,
  123.     it is identical to TGROUP.
  124.  
  125. TSRcode@
  126. TSRcodeEnd@
  127.     Delimit the code which will remain resident; some of the other
  128.     macros listed below will not function correctly unless within a
  129.     section of code delimited with TSRcode@ and TSRcodeEnd@.
  130.  
  131. TSRdata@
  132. TSRdataEnd@
  133.     Delimit the initialized data which will remain resident.  Requires the
  134.     use of TSRgroup@ to function properly.
  135.  
  136. TSRbss@
  137. TSRbssEnd@
  138.     Delimit the uninitialized data which will be placed in the resident
  139.     portion (but omitted from the disk image of the executable if
  140.     possible).    Requires the use of TSRgroup@ to function properly.
  141.  
  142. TSRgroup@
  143.     Declare TGROUP and force the correct ordering of TSRcode@, TSRdata@,
  144.     and TSRbss@.
  145.  
  146. DISPLAY_STRING
  147.     Output a '$'-terminated string to standard output via DOS.
  148.     Usage:
  149.     DISPLAY_STRING string,dataseg
  150.     Arguments:
  151.     string    the label of the string to be displayed
  152.     dataseg [opt] the segment of the string
  153.     Example:
  154.     DISPLAY_STRING banner
  155.     ...
  156.     ...
  157.     banner db "FOOBAR (c) 1992 Harry Q Bovik",13,10,"$"
  158.  
  159. CHECK_DOS_VER
  160.     Ensure that the program is running under the proper version of DOS,
  161.     and terminate with an error message specifying the minimum required
  162.     version if not.
  163.     Usage:
  164.     CHECK_DOS_VER  major,minor
  165.     Example:
  166.     CHECK_DOS_VER 2,00
  167.  
  168. IF_INSTALLED
  169.     Conditionally branch somewhere if the TSR is already installed.
  170.     Usage:
  171.     IF_INSTALLED dest
  172.     Arguments:
  173.     dest     label to branch to if already installed
  174.     Return:
  175.     falls through with CF clear if not already installed
  176.     branches with CF set and AH = multiplex number if installed
  177.  
  178. IF_HOTKEY_USED
  179.     Conditionally branch somewhere if one or more of the TSR's hotkeys
  180.     are already in use.
  181.     Usage:
  182.     IF_HOTKEY_USED dest
  183.     Arguments:
  184.     dest     label to branch to if hotkey conflict
  185.     Return:
  186.     falls through with CF clear if no hotkey conflict
  187.     branches with CF set and AX = bitmask of conflict types
  188.                 bit 0: exact key already in use
  189.                 bit 1: superset key already in use
  190.                 bit 2: subset key already in use
  191.  
  192. INSTALL_TSR
  193.     Allocate memory for the resident code, copy the resident code to the
  194.     allocated memory, hook all interrupts used by the TSR, optionally
  195.     call an initialization function, and terminate back to DOS.
  196.     Usage:
  197.     INSTALL_TSR extra,fit,high,init,if_inst,on_err,more_flags
  198.     Arguments:
  199.     extra    [opt] number of additional paragraphs needed in resident part
  200.     fit    [opt] FIRST or BEST (default) -fit allocation
  201.     high    [opt] HIGHONLY to only use UMBs, LOWONLY to only use
  202.             conventional memory, TOPMEM to allocate block at high 
  203.             end of conventional memory if no UMBs, TOPLOW
  204.             to only use top end of conventional memory
  205.     init    [opt] function to call after installing TSR but before exiting
  206.     if_inst [opt] label to branch to if already installed
  207.     on_err    [opt] label to branch to if unable to install
  208.     more_flags [opt] label of byte containing additional flags to be ORed
  209.            with those automatically set by <fit> and <high>
  210.     Notes:
  211.     If 'init' is specified, the indicated function will be called with
  212.         AX = segment at which TSR was loaded
  213.     If 'if_inst' is specified, the indicated function will be jumped at
  214.         with
  215.         AH = multiplex number
  216.         CX = version number
  217.     The TOPMEM and TOPLOW options are reported to be incompatible with
  218.         Windows 3.0, and will most likely cause a crash if the TSR is
  219.         installed while shelled out from a program using SPAWNO or
  220.         another swapping spawn() replacement.  Then again, anyone who
  221.         attempts to install a TSR while shelled out of another program
  222.         deserves whatever happens.
  223.  
  224. UNINSTALL
  225.     Remove the TSR from memory.
  226.     Usage:
  227.     UNINSTALL on_err
  228.     Arguments:
  229.     on_err      [opt] label to branch to if unable to remove from memory
  230.     Notes:
  231.     If 'on_err' is omitted, check CF after this macro to determine
  232.     whether the removal was successful (CF clear if successful, set
  233.     on error).
  234.  
  235. ISP_HEADER
  236.     Set up the Interrupt Sharing Protocol header for an interrupt.
  237.     Usage:
  238.     ISP_HEADER intr,reset,eoi
  239.     Arguments:
  240.     intr    interrupt number
  241.     reset    [opt] name of routine to perform hardware reset
  242.     eoi    [opt] if nonzero, this is the primary handler for a hardware int
  243.     Exported Labels: (for example "ISP_HEADER 00h,reset_func,0")
  244.     INT00h_handler (public), ORIG_INT00h (public), HWRESET_00h,
  245.     EOI_FLAG_00h
  246.     [in addition, hw_reset_00h would be present for ISP_HEADER 00h,,0]
  247.     Note:
  248.     This macro must be used inside a TSRcode@/TSRcodeEnd@ pair.
  249.     Example:
  250.     ISP_HEADER 21h
  251.         cmp    ah,4Bh    ; provide our own EXEC replacement
  252.         je    exec_call
  253.         jmp    ORIG_INT21h
  254.     exec_call:
  255.         ...
  256.  
  257. HOOKED_INTS
  258.     Declare the interrupts this TSR hooks.
  259.     Usage:
  260.     HOOKED_INTS  int1,int2,...,int32
  261.     Arguments:
  262.     up to 32 interrupt numbers
  263.     Exported Labels:
  264.     $AMIS$HOOKED_INT_LIST (public)
  265.     Notes:
  266.     This macro must be used inside a TSRcode@/TSRcodeEnd@ or
  267.     TSRdata@/TSRdataEnd@ pair.  INT 2Dh need not be listed, as it is
  268.     automatically added to the end of the list of hooked interrupts.
  269.     Examples:
  270.     HOOKED_INTS        ; this TSR hooks only INT 2Dh
  271.     HOOKED_INTS 13h,21h,FFh    ; this TSR hooks INTs 13h, 21h, 2Dh, FFh
  272.  
  273. HOTKEYS
  274.     Declare the type of hotkey check(s) used by this TSR.
  275.     Usage:    HOTKEYS type
  276.     Arguments:
  277.     type        when the TSR checks for it hotkey(s)
  278.     Exported Labels:
  279.     $AMIS$HOTKEY_LIST (public)
  280.     $AMIS$HOTKEY_LIST_START (internal use)
  281.     Note:
  282.     This macro must be followed immediately by one or more HOTKEY
  283.     macros, followed by the HOTKEYS_DONE macro.
  284.  
  285. HOTKEY
  286.     Declare one of the hotkeys used by this TSR.
  287.     Usage:    HOTKEY    scan,required,disallowed
  288.     Arguments:
  289.     scan        scan code for hotkey
  290.     required    shift states required for hotkey to be recognized
  291.     disallowed  shift states which must be inactive for hotkey
  292.  
  293. HOTKEYS_DONE
  294.     Indicate that the list of hotkey definitions is complete.
  295.     Usage:    HOTKEYS_DONE
  296.     Exported Labels:
  297.     $AMIS$NUM_HOTKEYS (internal use)
  298.  
  299. HOTKEY_DISPATCHER
  300.     Include code for a generic hotkey dispatcher on INT 15/AH=4Fh which
  301.     interprets the hotkey records created with the HOTKEYS, HOTKEY, and
  302.     HOTKEYS_DONE macros.
  303.     Usage:    HOTKEY_DISPATCHER chain,funcs,other
  304.     Arguments:
  305.     chain    when should dispatcher chain?  valid: BEFORE or AFTER
  306.     funcs    name of list of words containing offsets of functions
  307.     other    [opt] address to jump at if INT 15h invoked with AH != 4Fh
  308.     Exported Labels:
  309.     ORIG_INT15h
  310.     Note:
  311.     The list of hotkey handlers must be in the same order as the
  312.     hotkeys defined with multiple instances of the HOTKEY macro.
  313.  
  314. ALTMPX
  315.     Define the alternate multiplex interrupt handler for the program.
  316.     Usage:
  317.     ALTMPX manuf,prodname,version,descrip,priv,api,popup,remove,psp
  318.     Arguments:
  319.     manuf       one- to eight-character manufacturer's name
  320.     prodname   one- to eight-character product name
  321.     version       four-digit hex version number (hi byte = major, lo = minor)
  322.     descrip       [opt] string (max 63 char) describing the product
  323.     priv       [opt] name of routine to handle private INT 2Dh functions
  324.     api       [opt] name of FAR routine giving non-INT 2Dh API entry point
  325.     popup       [opt] name of function to call to request a popup
  326.     remove       [opt] name of function to call to remove TSR from memory
  327.     psp       [opt] if nonblank, set up patch word for memblk segment to
  328.              be returned if <remove> omitted; returns CS if both
  329.              <remove> and <psp> blank (in this case, INSTALL_TSR
  330.              must specify either TOPMEM or HIGHONLY)
  331.     Limitations on Routines:
  332.     <priv>    must be located in TSRcode@
  333.         input:    AL = function number (10h-FFh)
  334.             AH = multiplex number (ignore)
  335.             others available for handler
  336.         return: via IRET, with regs as appropriate for requested func
  337.     <api>    must be located in TSRcode@
  338.         input:    registers as desired (no limitations)
  339.         return: registers as desired (no limitations)
  340.     <popup> must be located in TSRcode@
  341.         input:    nothing
  342.         return: AL = status
  343.                 01h can not pop up now, try again later
  344.                 02h can not pop up yet, will do so when able
  345.                 03h already popped up
  346.                 04h unable to popup, user intervention required
  347.                     BX = standard reason code
  348.                     0000h unknown failure
  349.                     0001h int chain passes through memory
  350.                         which must be swapped out
  351.                     0002h swap-in failed
  352.                     CX = application's reason code if nonzero
  353.                 FFh TSR popped up and was exited by user
  354.                     BX = return value
  355.                     0000h no return value
  356.                     0001h TSR unloaded
  357.                     0002h-00FFh reserved
  358.                     0100h-FFFFh application-specific
  359.     <remove> must be located in TSRcode@
  360.         input:    DX:BX = return address if uninstall successful
  361.         return: AL = status
  362.                 01h unable to remove from memory
  363.                 02h can't remove now, will do so when able
  364.                 03h safe to remove, but no resident uninstaller
  365.                     (TSR still enabled)
  366.                     BX = segment of memory block
  367.                 04h safe to remove, but no resident uninstaller
  368.                     (TSR now disabled)
  369.                     BX = segment of memory block
  370.                 05h not safe to remove now, try again later
  371.                 FFh successful (DX:BX were ignored)
  372.         return at DX:BX with AX destroyed if successful and <remove>
  373.             honors specific return address
  374.         if <remove> omitted, ALTMPX returns AL=03h
  375.     Exported Labels:
  376.     INT2Dh_handler (public), ORIG_INT2Dh (public), HWRESET_2Dh,
  377.     EOI_FLAG_2Dh, hw_reset_2Dh, $AMIS$MULTIPLEX_NUMBER (public),
  378.     ALTMPX_SIGNATURE (public), ALTMPX$PSP [patch word if <psp> nonblank]
  379.     Note:
  380.     This macro must be used inside a TSRcode@/TSRcodeEnd@ pair.
  381.  
  382. ------------------------------------------------------------------------
  383.  
  384. For more details, see AMIS.MAC, AMIS.ASM, and the source to the example
  385. TSRs.  See also TSRS.DOC for usage information on the sample TSRs.
  386.  
  387. ------------------------------------------------------------------------
  388.  
  389.     Ralf Brown            [valid until November 1, 1993]
  390.     813 Copeland Way, Suite 26
  391.     Pittsburgh, PA 15232
  392.  
  393.     Ralf Brown 1:129/26.1
  394.     ralf+@cs.cmu.edu
  395.